﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Diplomova_prace
{
    public partial class SelectedMethod : Form
    {
        int selected = -1;
        Dictionary<int, string> DictTagName;
        public int GetSelectedMethod
        {
            get { return selected; }
        }
        public SelectedMethod(Dictionary<int,string> DictTagName)
        {
            this.DictTagName = DictTagName;
            InitializeComponent();
            Methods.Items.AddRange(DictTagName.Values.ToArray());   
        }

        private void Methods_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            SelectMethod();
        }

        private void Methods_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == System.Windows.Forms.Keys.Enter)
                SelectMethod();
        }
        private void SelectMethod()
        {
            if (Methods.SelectedItem != null)
            {
                selected = (int)DictTagName.FirstOrDefault(x => x.Value == Methods.SelectedItem.ToString()).Key;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
    }
}
